<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Admin_partenaires_add extends CI_Controller {

	function index()
	{
		$data['error'] ='display: none;';
		$data['partenaires']  ='active';
		if($this->session->userdata('email') || $this->session->userdata('logged'))
		{		
				$this->load->model('admin_model');	
				$data['message'] = $this->admin_model->list_message();
				$data['title'] = 'Admin Partenaires';	
				$data['content'] = 'admin/admin_partenaires_add';
				$this->load->view('admin/template/template',$data);
		}
		else 
		{
			$this->load->view('admin/signup',$data);
		}
	}

	function do_upload(){
			if($this->session->userdata('email') || $this->session->userdata('logged'))
			{
					$config['upload_path'] = './uploads/partenaires/';
					$config['allowed_types'] = 'gif|png|jpg|jpeg';
					$config['max_size'] = '3048';
					$config['encrypt_name'] = true;
					$this->load->library('upload',$config);

					if (!$this->upload->do_upload()) 
					{
						$this->lang->load('upload', $this->config->item('language'));
						$data['error_upload'] = $this->upload->display_errors();
						$data['title'] = 'Add Slider';
						$data['content'] = 'admin/admin_partenaires_add';
						$this->load->view('admin/template/template_DT',$data);
					} 
					else 
					{
						$image_data = $this->upload->data();
						$config = array(
							'image_library' => 'GD2', 
							'source_image' => $image_data['full_path'],
							'new_image' => './uploads/partenaires/thumbs/',
							'create_thumb' => TRUE,
							'thumb_marker' => '',
							'maintain_ratio' => FALSE,
							'width'=> 466,
							'height' => 311
						);
						$this->load->library('image_lib',$config);
						$this->image_lib->resize();
						$image_name = $image_data['file_name'];
						$this->load->model('admin_model');
						$data = array(
						'partenaires_photos' => $image_name,
						'partenaires_title' => $this->input->post('title'),
						'partenaires_link' => $this->input->post('link'),
						);

						$data['partenaires'] = $this->home_model->list_partenaires();	
						$data['message'] = $this->admin_model->list_message();
						$data['partenaires']  ='active';
						$data['success'] ='display: block;';
						$data['title'] = 'Admin Partenaires';	
						$data['content'] = 'admin/admin_partenaires';
						$this->load->view('admin/template/template',$data);
					}
			}
			else 
			{
				$this->load->view('admin/signup',$data);
			}	
		}
		
		
	}		
?>